//
//  YWColorPresentationController.m
//  YWPhotoEditMaster
//
//  Created by jun peng on 2023/8/3.
//

#import "YWColorPresentationController.h"

@interface YWColorPresentationController ()

@property(nonatomic,weak)UIView *coverView;

@end

@implementation YWColorPresentationController



-(void)containerViewWillLayoutSubviews{
    
    [super containerViewWillLayoutSubviews];
    
    // 1.设置弹出View的尺寸
    self.presentedView.frame = self.presentedFrame;
    
    // 2.添加蒙版
    [self setupCoverView];
}


-(void)setupCoverView{
    
    UIView *coverView = [[UIView alloc] init];
    self.coverView = coverView;
    
    // 1.添加蒙版
    [self.containerView insertSubview:self.coverView atIndex:0];
    
    // 2.设置蒙版的属性
    self.coverView.backgroundColor = [UIColor clearColor];
    self.coverView.frame = self.containerView.bounds;
    
    // 3.添加手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(coverViewClick)];
    [self.coverView addGestureRecognizer:tap];
    
}

-(void)coverViewClick{
    
    [self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
@end
